﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : BasePage
{    

    protected void Page_Load(object sender, EventArgs e)
    {        
        string textFromDB = string.Empty;
            
        textFromDB = GetText(textFromDB);        

        dataText.Text = textFromDB;        
    }

    #region Helper Methods
    public string GetText(string str)
    {        
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString);
        SqlDataReader rdr = null;

        conn.Open();

        SqlCommand cmd = new SqlCommand("Select [Text] FROM Source", conn);

        rdr = cmd.ExecuteReader();

        rdr.Read();

        str = rdr[0].ToString();
                    
        rdr.Close();

        conn.Close();

        return str;
    }
    #endregion 
}